
/*

	#define LOG_TO_FILE	 "d:/a.txt"
	#define LOG_TO_CONSOLE	 false
	#define LOG_TO_DEBUG true

	
*/

#pragma  once;

#include <windows.h>
#include <string>

using namespace std;

namespace yet{

//#define LOG_TO_FILE "d:/test/a.txt"

class Logger{
	friend Logger& err(Logger& slog);
	friend Logger& error(Logger& slog);
public:
	static void SetLogFile(string logfile);
	static void SetToConsole(bool toConsole);
	static void SetToDebugWindow(bool toDebugWindow);
private:
	static bool toConsole;
	static bool toDebugWindow;
	static string filename;
public:
	Logger(string filename = "", bool toConsole = true, bool toDebugWindow = true);
public:
	void Append(const string& s, UINT cp = GetACP());
	void Append(const wstring& ws);
	size_t Length()const ;
	void Flush();
protected:
	string buf;
	bool isErr;

};


Logger& operator << (Logger& slog, Logger& (*pFun)(Logger&) );
Logger& Timestamp(Logger& slog);
Logger& ThreadID(Logger& slog);
Logger& endl(Logger& slog);
Logger& endln(Logger& slog);
Logger& flush(Logger& slog);

Logger& info(Logger& slog);
Logger& err(Logger& slog);
Logger& error(Logger& slog);
Logger& warn(Logger& slog);
Logger& dbg(Logger& slog);
Logger& debug(Logger& slog);





Logger& operator << (Logger& slog, bool val);
Logger& operator << (Logger& slog, char val);
Logger& operator << (Logger& slog, unsigned char val);
Logger& operator << (Logger& slog, short val);
Logger& operator << (Logger& slog, unsigned short val);
Logger& operator << (Logger& slog, wchar_t val);//vs Ĭ����wchar_tΪ��������!!
Logger& operator << (Logger& slog, int val);
Logger& operator << (Logger& slog, unsigned int val);
Logger& operator << (Logger& slog, long val);
Logger& operator << (Logger& slog, unsigned long val);
Logger& operator << (Logger& slog, float val);
Logger& operator << (Logger& slog, double val);
Logger& operator << (Logger& slog, long double val);
//
Logger& operator << (Logger& slog, char* s);
Logger& operator << (Logger& slog, wchar_t* ws);
Logger& operator << (Logger& slog, const char* s);
Logger& operator << (Logger& slog, const wchar_t* ws);
//
Logger& operator << (Logger& slog, string& s);
Logger& operator << (Logger& slog, wstring& ws);
Logger& operator << (Logger& slog, const string& s);
Logger& operator << (Logger& slog, const wstring& ws);



extern Logger Log;



}


